<!DOCTYPE html>
<html lang="en">
	<head>
		<meta charset="UTF-8" />
		<meta http-equiv="X-UA-Compatible" content="IE=edge" />
		<meta name="viewport" content="width=device-width, initial-scale=1.0" />
		<title>更改密码</title>
		<link rel="stylesheet" href="css/bootstrap.css" />
		<link rel="stylesheet" href="css/login.css" />
	</head>
	<body>
		<div class="container">
			<h2>D</h2>
			<p>更改密码</p>
			<form id="change_password">
				<input type="password" id="password" required placeholder="输入密码" />
				<input type="password" id="password2" required placeholder="确认密码" />
				<input type="submit" id="sub" value="修改密码" />
			</form>
			<div class="forget">
				<a href="javascript:history.back(-1)"> 返回</a>
				<a href="register.html"> </a>
			</div>
		</div>

		<div id="myAlert" class="alert alert-success col-sm-4 col-sm-offset-3">
			<a href="#" class="close" data-dismiss="alert">&times;</a>
			<strong>文章发布成功!!!</strong>
		</div>
	</body>
	<script src="node_modules/axios/dist/axios.js"></script>

	<script src="js/register.js"></script>
	<script>
		let admin = new Admin();
		//判断是否有权限
		admin.jurisdiction();

		document.querySelector("#change_password").addEventListener("submit", (e) => {
			e.preventDefault();
			let formdata = new FormData();
			formdata.append("id", admin.getlocationId());
			formdata.append("password", admin.getVal("#password"));
			formdata.append("password2", admin.getVal("#password2"));
			axios
				.post("https://ty.php800.cn/api/member/userPassword.php", formdata)
				.then((result) => {
					console.log(result.data);
					let { verify, msg } = result.data;
					admin.popUpBox(verify, msg);
				})
				.catch((err) => console.log(err));
		});
	</script>
</html>
